﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ProduceBasicData.Api.Controllers
{
    /// <summary>
    /// 上传控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ImgController : ControllerBase
    {
        /// <summary>
        /// 上传接口
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpImg(IFormFile file)
        {
            string p=Directory.GetCurrentDirectory()+@"/wwwroot/Pic/"+file.FileName;
            using (FileStream fs = new FileStream(p, FileMode.Create))
            {
                file.CopyTo(fs);
                fs.Flush();
            }
            //return Ok("http://localhost:5097/Pic/" + file.FileName);//本地
            //return Ok("http://118.178.145.62:9915/Pic/" + file.FileName);//服务器
           // return Ok("http://114.215.202.217:9920/Pic/" + file.FileName);//docker
            return Ok("http://43.138.8.209:9920/Pic/" + file.FileName);//腾讯云
        }
    }
}
